﻿using System;
using System.Windows.Forms;

namespace LastfmTopDownloader
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (Settings1.Default.FirstLaunch)
            {
                button2_Click(sender, e);
            }

            var result = DialogResult.None;
            while (result != DialogResult.OK)
            {
                result = folderBrowserDialog1.ShowDialog();
                if ((result == DialogResult.Cancel) || (result == DialogResult.Abort))
                    return;
                VkDownloader.Path = folderBrowserDialog1.SelectedPath;
            }

            var statusFrom = new StatusForm(textBox1.Text);

            statusFrom.Shown += (o, eventArgs) => statusFrom.WriteTable();
            statusFrom.ShowDialog();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Vk.Authorize();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            button1.Enabled = !String.IsNullOrWhiteSpace(textBox1.Text);
        }
    }
}
